#!/usr/bin/env node

const http = require('http');
const log = console.log;

function select(req,res) {
    log(req.method);
    res.end(req.method);
};
const insert = select,
      update = select,
      remove = select;

http.createServer((req,res)=>{
    switch(req.method){
        case 'GET':
            select(req,res);
            break;
        case 'POST':
            insert(req,res);
            break;
        case 'PUT':
            update(req,res);
            break;
        case 'DELETE':
            remove(req,res);
            break;
        default:
            res.end(`${req.method} not support!`);
    }
}).listen(8080);


